home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Software Contest 3 / FM Towns Software Contest 3.iso / exp / astral / a1 / game / source / roll.c < prev    next >
C/C++ Source or Header  |  1994-01-07  |  1KB  |  51 lines

  1. #include "wire3d.h"
  2. #include "sin.dat"
  3. #include <stdio.h>
  4.  
  5. void roll(int *s_point,int *d_point,unsigned char *angle,int *offset)
  6. {
  7.     int point_w[4][3];
  8.     int z_w;
  9.     
  10.     #ifdef TEST
  11.         printf("s:x=%4d,y=%4d,z=%4d\n",s_point[0],s_point[1],s_point[2]);
  12.     #endif
  13.     
  14.     point_w[0][0]=s_point[0];
  15.     point_w[0][1]=s_point[1];
  16.     point_w[0][2]=s_point[2];
  17.         
  18.     /* X軸の回転 */
  19.     point_w[1][0]= point_w[0][0];
  20.     point_w[1][1]=(point_w[0][1]*cos[angle[0]]+point_w[0][2]*sin[angle[0]])>>16;
  21.     point_w[1][2]=(-point_w[0][1]*sin[angle[0]]+point_w[0][2]*cos[angle[0]])>>16;
  22.     
  23.     /* Y軸の回転 */
  24.     point_w[2][0]=(point_w[1][0]*cos[angle[1]]-point_w[1][2]*sin[angle[1]])>>16;
  25.     point_w[2][1]= point_w[1][1];
  26.     point_w[2][2]=(point_w[1][0]*sin[angle[1]]+point_w[1][2]*cos[angle[1]])>>16;
  27.     
  28.     /* Z軸の回転 */
  29.     point_w[3][0]=((point_w[2][0]*cos[angle[2]]+point_w[2][1]*sin[angle[2]])>>16)+offset[0];
  30.     point_w[3][1]=((-point_w[2][0]*sin[angle[2]]+point_w[2][1]*cos[angle[2]])>>16)+offset[1];
  31.     point_w[3][2]= point_w[2][2]+offset[2];
  32.     
  33.     /* 視角の調整 */
  34.     z_w=point_w[3][2]*SIGHT_ANGLE+65536;
  35.     #ifdef TEST
  36.         printf("z_w=%f\n",z_w);
  37.     #endif
  38.     point_w[3][0]=(int)((point_w[3][0]<<16)/z_w);
  39.     point_w[3][1]=(int)((point_w[3][1]<<16)/z_w);
  40.     point_w[3][2]=(int)((point_w[3][2]<<16)/z_w);
  41.     
  42.     d_point[0]=point_w[3][0];
  43.     d_point[1]=point_w[3][1];
  44.     d_point[2]=point_w[3][2];
  45.     
  46.     #ifdef TEST
  47.         printf("d:x=%4d,y=%4d,z=%4d\n",d_point[0],d_point[1],d_point[2]);
  48.     #endif
  49.     
  50. }
  51.